package com.epoint.mobileoa.ui.statistics;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.dom4j.Element;

import android.os.Message;

import com.epoint.mobileoa.bizlogic.SuperView;
import com.epoint.mobileoa.bizlogic.Task;
import com.epoint.mobileoa.datanalysis.XMLHelp;
import com.epoint.mobileoa.http.HttpHelp;
import com.epoint.mobileoa.personalized.epointcompany.model.GongzuoRzDetailModel;

/**
 * @author liyc
 * @time 2012-5-4 上午10:36:02
 * @annotation 
 */
public class GetStatisticsInfoTask extends Task {

	/**
	 * @param con
	 * @param param
	 */
	public GetStatisticsInfoTask(SuperView con, HashMap<String, Object> param) {
		super(con, param);
	}

	@Override
	public void exectue(Message mess) throws Exception {
		String seamurl = generateURL("GetStatisticsInfo");
		String bs = HttpHelp.getHttpBack(seamurl);
		setMessageToRefreshUI(mess, getCon(), bs);
	}
	
	public static List<StatisticsModel> XmlAnalysis(String xml){
		List focs = XMLHelp.getRoot(xml).elements();
		List<StatisticsModel> plist = new ArrayList<StatisticsModel>();
		for (int i = 0; i < focs.size(); i++) {
			StatisticsModel mt = new StatisticsModel();
			Element foc = (Element) focs.get(i);
			if (foc.element("USERGUID") != null)
				mt.USERGUID = foc.elementText("USERGUID");
			if (foc.element("DISPLAYNAME") != null)
				mt.DISPLAYNAME = foc.elementText("DISPLAYNAME");
			if (foc.element("OUNAME") != null)
				mt.OUNAME = foc.elementText("OUNAME");
			if (foc.element("LOGINTIMES") != null)
				mt.LOGINTIMES = foc.elementText("LOGINTIMES");
			if (foc.element("LASTLOGINDATE") != null)
				mt.LASTLOGINDATE = foc.elementText("LASTLOGINDATE");
			if (foc.element("ENABLE") != null)
				mt.ENABLE = foc.elementText("ENABLE");
			if (foc.element("ISONLINE") != null)
				mt.ISONLINE = foc.elementText("ISONLINE");
			if (foc.element("DEVICEID") != null)
				mt.DEVICEID = foc.elementText("DEVICEID");
			plist.add(mt);
		}
		return plist;
	}

}
